﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EntityDesigner2.Extensions
{
    public static class ControlExtensions
    {
        public static Point GetPositionInForm(this Control control)
        {
            //Debug.WriteLine($"[GetPositionInForm] {control.GetType().FullName}");
            if (control is null) return new Point(0, 0);
            if (control.Parent is null) return new Point(0, 0);
            Point point = control.Parent.GetPositionInForm();
            //Debug.WriteLine($"[GetPositionInForm] {control.GetType().FullName}:{control.Location} + {point}");
            return new Point(control.Location.X + point.X, control.Location.Y + point.Y);
        }
    }
}
